package com.itheima.sh.controller;

import com.itheima.sh.pojo.User;
import com.itheima.sh.service.UserService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("user")
@Log4j2
public class UserController {

    @Autowired
    private UserService userService;
    @Value("${server.port}")
    private Integer port;

    @GetMapping("/{id}")
    public User queryById(@PathVariable("id") String username , HttpServletRequest request) {
        log.info("server port is:   " + port);
        String name = request.getHeader("name");
        log.info("getname...." + name);
        return userService.queryById(username);
    }
}
